unit UntImportTxt;

interface

function getTxtS(s: string; posInicial, posFinal: Integer): string;
function getTxtI(s: string; posInicial, posFinal: Integer): Integer;
function getTxtC(s: string; posInicial, posFinal: Integer): Currency;
function getTxtD(s: string; posInicial, posFinal: Integer): TDate;

implementation

uses SysUtils, Windows;

function getTxtS(s: string; posInicial, posFinal: Integer): string;
begin
  Result := Copy(s,posInicial, (posFinal-posInicial+1));
end;

function getTxtI(s: string; posInicial, posFinal: Integer): Integer;
begin
  Result := StrToInt(Copy(s,posInicial, (posFinal-posInicial+1)));
end;

function getTxtC(s: string; posInicial, posFinal: Integer): Currency;
begin
  Result := StrToCurr(Copy(s,posInicial, (posFinal-posInicial+1))) / 100;
end;

function getTxtD(s: string; posInicial, posFinal: Integer): TDate;
var d:string;
    yy,mm,dd: Word;
begin
  d := Copy(s,posInicial, (posFinal-posInicial+1));
  yy := StrToInt(Copy(d,1,4));
  mm := StrToInt(Copy(d,5,2));
  dd := StrToInt(Copy(d,7,2));
  Result := EncodeDate(yy,mm,dd);
end;

end.
